package com.provider.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.provider.dao.TBucketDao;
import com.provider.entity.TBucket;
import com.provider.entity.TBucketFile;
import com.provider.entity.TProjectDemandPool;
import com.provider.service.TBucketFileService;
import com.provider.service.TBucketService;
import com.provider.service.TProjectDemandPoolService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 桶(TBucket)表服务实现类
 *
 * @author makejava
 * @since 2024-04-26 14:24:58
 */

@Service
@Transactional(rollbackFor = Exception.class)
public class TBucketServiceImpl extends ServiceImpl<TBucketDao, TBucket> implements TBucketService {
    @Resource
    TBucketDao tBucketDao;


    @Resource
    TBucketFileService  bucketFileService;


    @Resource
    TProjectDemandPoolService projectDemandPoolService;
    @Override
    public List<TBucket> queryByProjectId(String projectId) {
        LambdaQueryWrapper<TBucket> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(TBucket::getSystemId, projectId).eq(TBucket::getSystemType,"1");
        return tBucketDao.selectList(lambdaQueryWrapper);
    }

    @Override
    public List<TBucket> queryByPlanId(String planId) {
        LambdaQueryWrapper<TBucket> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(TBucket::getSystemId, planId).eq(TBucket::getSystemType,"2");
        return this.list(lambdaQueryWrapper);
    }

    @Override
    public List<TBucket> queryAllBucket() {
        return this.list();

    }

    @Override
    public List<TBucketFile> queryBucketFileByProjectId(String projectId) {
        LambdaQueryWrapper<TBucketFile> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(TBucketFile::getBucketId, projectId);
        return bucketFileService.list(lambdaQueryWrapper);
    }

    @Override
    public List<TBucketFile> queryAllBucketFile() {
        return bucketFileService.list();
    }


}